package putYourHands.dao;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.transaction.annotation.Transactional;

import putYourHands.model.Paciente;

public class PacienteDaoImpl extends HibernateDaoSupport implements PacienteDao {

	public PacienteDaoImpl(){
		
	}
	
	public PacienteDaoImpl(SessionFactory sessionFactory) {
		this.setSessionFactory(sessionFactory);
	}

	@Transactional
	public void delete(Paciente paciente) {
		this.getHibernateTemplate().delete(paciente);
	}

	@Transactional(readOnly=true)
	public void find(Long id) {
		this.getHibernateTemplate().load(Paciente.class, id);
	}

	@Transactional(readOnly = true)
	public List<Paciente> findAll() {
		return this.getHibernateTemplate().find("from Paciente");
	}

	@Transactional
	public void saveOrUpdate(Paciente paciente) {
		this.getHibernateTemplate().saveOrUpdate(paciente);

	}

}
